package com.hancheng.goodscloud.framework.kafka;

import lombok.extern.slf4j.Slf4j;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.kafka.support.Acknowledgment;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class GoodsKafkaConsumer {

    @KafkaListener(topics = "order-events")
    public void listenOrderEvent(String message, Acknowledgment ack) {
        try {
            log.info("我接受到订单模块发送的消息: {}", message);
            //手动提交
            ack.acknowledge();
        } catch (Exception e) {
            log.info("消息处理失败：{}" + e.getMessage());
            // 不 ack，消息将再次消费（可实现重试机制）
        }
    }
}
